<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/fingerprint.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/jquery-1.10.1.min.js",CClientScript::POS_HEAD);
//Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);


Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.core.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.widget.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.scroller.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.util.datetime.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.datetimebase.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.widget.ios.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/mobiscroll/js/mobiscroll.i18n.zh.js",CClientScript::POS_HEAD);




Yii::app()->clientScript->registerCssFile("//cdn.bootcss.com/weui/0.4.3/style/weui.min.css");
Yii::app()->clientScript->registerCssFile("//cdn.bootcss.com/jquery-weui/0.8.0/css/jquery-weui.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/demo.css");
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/alert.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/js_mobile_common_new.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/sweetalert.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/js/demo.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile("//cdn.bootcss.com/jquery-weui/0.8.0/js/swiper.min.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScriptFile("//cdn.bootcss.com/jquery-weui/0.8.0/js/jquery-weui.min.js",CClientScript::POS_HEAD);

?>

<form method="post" action="<?php echo $this->createUrl('Upload')?>" id="uform" enctype="multipart/form-data">
    <div class="weui_cells weui_cells_form">
    	<div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
          <input class="weui_input" id="title" name="title" type="text" placeholder="作品标题">
        </div>
      </div>
      <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
          <textarea class="weui_textarea" id="desc" name="desc" placeholder="作品描述" rows="3"></textarea>
        </div>
      </div>
      <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
          <div class="weui_uploader">
            <div class="weui_uploader_hd weui_cell">
              <div class="weui_cell_bd weui_cell_primary">图片上传</div>
              
            </div>
            <div class="weui_uploader_bd">
              <ul class="weui_uploader_files">
                <li class="weui_uploader_file"  id="img_id" style="display:none;" >
                <img id="img0" src="" width="80" height="80" />
                </li>
              </ul>
              <div class="weui_uploader_input_wrp">
                <input class="weui_uploader_input" name="file0" id="file0" type="file" accept="image/*" multiple="" >
              </div>
            </div>
          </div>
        </div>
      </div>
       <div class="weui_btn_area">
        <a class="weui_btn weui_btn_warn" href="javascript:" id="showTooltips">上传</a>
      </div>
    </div>
    </form>
    <script>	
$("#file0").change(function(){
	var objUrl = getObjectURL(this.files[0]) ;
	console.log("objUrl = "+objUrl) ;
	if (objUrl) {
		$("#img0").attr("src", objUrl) ;
		$("#img_id").show();
	}
}) ;
//建立一個可存取到該file的url
function getObjectURL(file) {
	var url = null ; 
	if (window.createObjectURL!=undefined) { // basic
		url = window.createObjectURL(file) ;
	} else if (window.URL!=undefined) { // mozilla(firefox)
		url = window.URL.createObjectURL(file) ;
	} else if (window.webkitURL!=undefined) { // webkit or chrome
		url = window.webkitURL.createObjectURL(file) ;
	}
	return url ;
}
$("#showTooltips").bind("click",function(){
	$("#uform").submit();
});
</script>